﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using QuizzAdminData;

namespace QuizzAdmin
{
    /// <summary>
    /// 
    /// </summary>
    /// <returns></returns>
    /// <author>Kenny Vaneetvelde</author>
    public partial class MainForm : Form
    {
        public MainForm()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void SpelersButton_Click(object sender, EventArgs e)
        {
            SpelersForm frm = new SpelersForm();
            frm.StartPosition = FormStartPosition.CenterScreen;
            frm.Show();
        }

        private void btnTeams_Click(object sender, EventArgs e)
        {
            MaakTeamForm frm = new MaakTeamForm();
            frm.StartPosition = FormStartPosition.CenterScreen;
            frm.Show();
        }

        private void btnVragen_Click(object sender, EventArgs e)
        {
            VragenForm frm = new VragenForm();
            frm.StartPosition = FormStartPosition.CenterScreen;
            frm.Show();
        }

        private void btnBackup_Click(object sender, EventArgs e)
        {
            string file = "";

            dlgBackupFileSave.Filter = "DB Backup files | *.dbbak";
            dlgBackupFileSave.DefaultExt = "dbbak";

            if (dlgBackupFileSave.ShowDialog() == DialogResult.OK)
            {
                file = dlgBackupFileSave.FileName;
                try
                {
                    DBMaintenance.BackupDB(file);
                    MessageBox.Show("Database backup gemaakt naar " + file);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }

        private void btnRestore_Click(object sender, EventArgs e)
        {
            string file = "";

            dlgBackupFileOpen.Filter = "DB Backup files | *.dbbak";
            dlgBackupFileOpen.DefaultExt = "dbbak";

            if(dlgBackupFileOpen.ShowDialog() == DialogResult.OK) {
                file = dlgBackupFileOpen.FileName;
                try
                {
                    DBMaintenance.RestoreDB(file);
                    MessageBox.Show("Database restore compleet.");
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }

        private void btnSpel_Click(object sender, EventArgs e)
        {
            MaakSpelForm frm = new MaakSpelForm();
            frm.StartPosition = FormStartPosition.CenterScreen;
            frm.Show();
        }
    }
}
